/* 
 * Enterprise Library Extensions - DI + ORM.
 * Copyright (C) 2006
 *
 * GNU General Public License
 *
 * This program is free software; you can redistribute 
 * it and/or modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 */
using System;
using System.Collections.Generic;
using System.Text;

namespace ELE.EnterpriseLibrary.Data
{
  /// <summary>
  /// A set of SQL to object mappings.
  /// </summary>
  public class ObjectSqlMappingSet
  {
    private Dictionary<string, ObjectSqlMapping> mappings;
    /// <summary>
    /// Adds an object mapping to the set.
    /// </summary>
    /// <param name="objectMapping"></param>
    public void AddObjectMapping(ObjectSqlMapping objectMapping)
    {
      if (mappings == null)
      {
        mappings = new Dictionary<string, ObjectSqlMapping>();
      }
      mappings.Add(objectMapping.Name, objectMapping);
    }
    /// <summary>
    /// Retrieves an object mapping by its id.
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public ObjectSqlMapping GetObjectMapping(string id)
    {
      if (mappings.ContainsKey(id))
      {
        return mappings[id];
      }
      return null;
    }
    /// <summary>
    /// The dictionary of the mappings.
    /// </summary>
    public Dictionary<string, ObjectSqlMapping> Mappings
    {
      get { return mappings; }
    }
  }
}
